import threading
import time, random

# event mechanism
t_event = threading.Event()


def moving():
    for i in range(1):
        # time.sleep(random.randrange(0, 1))
        print(threading.currentThread().getName(), 'waiting')
        t_event.wait() # 阻塞等待所有线程集合
        print(threading.currentThread().getName(), 'started')


list_a = []
for i in range(15):
    t = threading.Thread(target=moving)
    list_a.append(t)
t_event.clear() # 清除线程状态，等待指令

[i.start() for i in list_a]
t_event.set() # 开始执行
[i.join() for i in list_a]
print('complete!')
